package com.lenovo.smarttraffic.Test.hj_mitor;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

import com.lenovo.smarttraffic.R;


public class SetYuZhiActivity extends AppCompatActivity {

    private TextView tv_switch;
    private Switch switch_yuZhi;
    private EditText et_temp;
    private EditText et_hum;
    private EditText et_light;
    private EditText et_co2;
    private EditText et_pm2;
    private EditText et_road;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_yu_zhi);
        initView();
    }

    private void initView() {
        tv_switch = (TextView) findViewById(R.id.tv_switch);
        switch_yuZhi = (Switch) findViewById(R.id.switch_yuZhi);
        et_temp = (EditText) findViewById(R.id.et_temp);
        et_hum = (EditText) findViewById(R.id.et_hum);
        et_light = (EditText) findViewById(R.id.et_light);
        et_co2 = (EditText) findViewById(R.id.et_co2);
        et_pm2 = (EditText) findViewById(R.id.et_pm2);
        et_road = (EditText) findViewById(R.id.et_road);
    }

    private void submit() {
        // validate
        String temp = et_temp.getText().toString().trim();
        if (TextUtils.isEmpty(temp)) {
            Toast.makeText(this, "temp不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        String hum = et_hum.getText().toString().trim();
        if (TextUtils.isEmpty(hum)) {
            Toast.makeText(this, "hum不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        String light = et_light.getText().toString().trim();
        if (TextUtils.isEmpty(light)) {
            Toast.makeText(this, "light不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        String co2 = et_co2.getText().toString().trim();
        if (TextUtils.isEmpty(co2)) {
            Toast.makeText(this, "co2不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        String pm2 = et_pm2.getText().toString().trim();
        if (TextUtils.isEmpty(pm2)) {
            Toast.makeText(this, "pm2不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        String road = et_road.getText().toString().trim();
        if (TextUtils.isEmpty(road)) {
            Toast.makeText(this, "road不能为空", Toast.LENGTH_SHORT).show();
            return;
        }

        // TODO validate success, do something


    }
}
